package level.editor.menu;

import level.editor.command.Command;
import level.editor.command.RequiresModify;
import level.editor.command.RequiresModule;
import level.editor.command.RequiresUpdate;
import level.editor.mediator.Module;
import level.editor.state.StateModule;
import level.state.StateHandler;

public class UndoCommand extends Command implements RequiresUpdate,
		RequiresModify, RequiresModule
{
	public UndoCommand()
	{
		super("StateModule");
	}

	@Override
	public void execute(Module m)
	{
		StateModule module = (StateModule) m;
		if (module.getMemento().isPositionZero())
		{
			module.setModified(false);
			return;
		}
		module.setState(StateHandler.copy(module.getMemento().undo()));
	}

}
